home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / sonido / sfxserve.000 / sfxserve / sfxserver-0.02 / error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-10  |  3.4 KB  |  139 lines

  1. /*
  2.  * ---------------------------------------------------------------------------
  3.  * sfxserver/error.c
  4.  *
  5.  * Copyright by Terry Evans 1994
  6.  * tevans@cs.utah.edu, tevans@slc.unisys.com
  7.  * ---------------------------------------------------------------------------
  8.  *
  9.  * Redistribution and use in source and binary forms, with or without
  10.  * modification, are permitted provided that the following conditions are
  11.  * met: 1. Redistributions of source code must retain the above copyright
  12.  * notice, this list of conditions and the following disclaimer. 2.
  13.  * Redistributions in binary form must reproduce the above copyright notice,
  14.  * this list of conditions and the following disclaimer in the documentation
  15.  * and/or other materials provided with the distribution.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
  18.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20.  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  21.  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23.  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24.  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27.  * SUCH DAMAGE.
  28.  * ---------------------------------------------------------------------------
  29.  */
  30.  
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <stdarg.h>
  34.  
  35.  
  36. #include "error.h"
  37.  
  38.  
  39. void E_ErrnoFatalError(char *name, ...)
  40. {
  41.   extern int errno, sys_nerr;
  42.   extern char *sys_errlist[];
  43.  
  44.   va_list args;
  45.  
  46.   /* Function name and format */
  47.   char *format;
  48.  
  49.   /* Start the variable args */
  50.   va_start(args, name);
  51.  
  52.   format = va_arg(args, char *);
  53.  
  54.   fprintf(stderr, "%s: ", name);
  55.   vfprintf(stderr, format, args);
  56.   fprintf(stderr, "\n");
  57.  
  58.   /* See if we have a valid errno */
  59.   if(errno > 0 && errno < sys_nerr)
  60.     fprintf(stderr, "  errno = %d (%s)\n", errno, sys_errlist[errno]);
  61.  
  62.   /* Start the variable args */
  63.   va_end(args);
  64.  
  65.   exit(-1);
  66. }
  67.  
  68.  
  69. void E_ErrnoNonFatalError(char *name, ...)
  70. {
  71.   extern int errno, sys_nerr;
  72.   extern char *sys_errlist[];
  73.  
  74.   va_list args;
  75.  
  76.   /* Function name and format */
  77.   char *format;
  78.  
  79.   /* Start the variable args */
  80.   va_start(args, name);
  81.  
  82.   format = va_arg(args, char *);
  83.  
  84.   fprintf(stderr, "%s: ", name);
  85.   vfprintf(stderr, format, args);
  86.   fprintf(stderr, "\n");
  87.  
  88.   /* See if we have a valid errno */
  89.   if(errno > 0 && errno < sys_nerr)
  90.     fprintf(stderr, "  errno = %d (%s)\n", errno, sys_errlist[errno]);
  91.  
  92.   /* Start the variable args */
  93.   va_end(args);
  94. }
  95.  
  96.  
  97. void E_FatalError(char *name, ...)
  98. {
  99.   va_list args;
  100.  
  101.   /* Function name and format */
  102.   char *format;
  103.  
  104.   /* Start the variable args */
  105.   va_start(args, name);
  106.  
  107.   format = va_arg(args, char *);
  108.  
  109.   fprintf(stderr, "%s: ", name);
  110.   vfprintf(stderr, format, args);
  111.   fprintf(stderr, "\n");
  112.  
  113.   /* Start the variable args */
  114.   va_end(args);
  115.  
  116.   exit(-1);
  117. }
  118.  
  119.  
  120. void E_NonFatalError(char *name, ...)
  121. {
  122.   va_list args;
  123.  
  124.   /* Function name and format */
  125.   char *format;
  126.  
  127.   /* Start the variable args */
  128.   va_start(args, name);
  129.  
  130.   format = va_arg(args, char *);
  131.  
  132.   fprintf(stderr, "%s: ", name);
  133.   vfprintf(stderr, format, args);
  134.   fprintf(stderr, "\n");
  135.  
  136.   /* Start the variable args */
  137.   va_end(args);
  138. }
  139.